package com.tantou.leetcode.easy;

/**
 * @author jiangweiyang
 * @created 2020/4/29 19:37
 **/
public class ReverseInteger {

    /**
     * https://leetcode-cn.com/problems/reverse-integer/solution/javazheng-shu-fan-zhuan-by-xuebuhui0729/
     */
    public static void main(String[] args) {
        System.out.println(normal(1463847412));
    }


    public static int normal(int x) {
        int ret = 0;
        while(x!=0){
            int tmp = ret*10 +x%10;
            if((tmp-x%10)/10!=ret){
                return 0;
            }
            ret = tmp;
            x=x/10;
        }
        return ret;
    }
}
